<?php
/**
 * uri library
 *
 * uri libarry
 *
 * Created on 2012. 2. 6.
 * @author 이름 <이메일>
 * @package application
 * @subpackage libraries
 * @category uri
 * @version 1.0
 */


class Uri_library {
	private $ci;

	/**
	 *
	 * construct
	 */
	function __construct()
	{
		$this->ci = &get_instance();
		define('CONTROLLER', $this->ci->uri->rsegment(1));
		define('METHOD', $this->ci->uri->rsegment(2));
	}

	function secure_site_url($uri = '')
	{
		if (is_array($uri))
		{
			$uri = implode('/', $uri);
		}

		if ($uri == '')
		{
			return $this->ci->config->slash_item('secure_base_url').$this->ci->config->item('index_page');
		}
		else
		{
			$suffix = ($this->ci->config->item('url_suffix') == FALSE) ? '' : $this->ci->config->item('url_suffix');
			return $this->ci->config->slash_item('secure_base_url').$this->ci->config->slash_item('index_page').preg_replace("|^/*(.+?)/*$|", "\\1", $uri).$suffix;
		}
	}

	function getDomain()
	{
		return preg_replace("/^[\w]{2,6}:\/\/([\w\d\.\-]+).*$/","$1", $this->ci->config->slash_item('base_url'));
	}

	function url_encode($str) {
		return strtr(base64_encode(addslashes(gzcompress(serialize($str), 9))), '+/=', '-_.');
	}

	function url_decode($str) {
		return unserialize(gzuncompress(stripslashes(base64_decode(strtr($str, '-_.', '+/=')))));
	}
}


/* End of file uri_library.php */
/* Location:  /application/libraries/uri_library.php */
?>